#include "abuf.h"

int main()
{
	struct AppendBuffer	*buf = NULL ;
	size_t			*buf_size = NULL ;
	char			**base = NULL ;
	char			**fill_ptr = NULL ;
	int			i ;
	
	int			nret = 0 ;
	
	buf = AllocBufferInitSize( 16 ) ;
	if( buf == NULL )
	{
		printf( "AllocBufferInitSize failed\n" );
		return 1;
	}
	else
	{
		printf( "AllocBufferInitSize ok\n" );
	}
	
	buf_size = GetAppendBufferSizePtr( buf ) ;
	base = GetAppendBufferBasePtr( buf ) ;
	fill_ptr = GetAppendBufferFillPtrPtr( buf ) ;
	
	for( i = 1 ; i <= 20 ; i++ )
	{
		nret = AppendBufferString( buf , "1" );
		if( nret <= 0 )
		{
			printf( "i[%d] AppendBufferString failed[%d]\n" , i , nret );
			return 1;
		}
		else
		{
			printf( "i[%d] AppendBufferString ok , buf_size[%zu] base[0x%p] fill_ptr[0x%p] - str[%zu][%s]\n" , i , (*buf_size) , (*base) , (*fill_ptr) , GetAppendBufferLength(buf) , GetAppendBufferBase(buf) );
		}
	}
	
	for( i = 1 ; i <= 20 ; i++ )
	{
		nret = AppendBufferFormatString( buf , "%.1s" , "2" );
		if( nret <= 0 )
		{
			printf( "i[%d] AppendBufferFormatString failed[%d]\n" , i , nret );
			return 1;
		}
		else
		{
			printf( "i[%d] AppendBufferFormatString ok , buf_size[%zu] base[0x%p] fill_ptr[0x%p] - str[%zu][%s]\n" , i , (*buf_size) , (*base) , (*fill_ptr) , GetAppendBufferLength(buf) , GetAppendBufferBase(buf) );
		}
	}
	
	printf( "FreeBuffer ok\n" );
	FreeBuffer( buf );
	
	return 0;
}

